package aclInfoCollector.filesAnalysers.component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import org.w3c.dom.Document;
import aclInfoCollector.utils.specialString.StringInterface;

public abstract class ComponentFileAnalyser implements  IComponentFileAnalyser
{
	protected ArrayList<String> components;
	protected ArrayList<String> componentsWithArgs;
	protected ArrayList<StringInterface> interfaces;
	protected HashMap<String, ArrayList<StringInterface>> componentsWithInterfaces;
	protected HashMap<String, ArrayList<String>> componentsWithSuperComps;
	protected Document document;
	protected String text;
	
	
	

	public ComponentFileAnalyser() {
		components = new ArrayList<String>();
		componentsWithArgs = new ArrayList<String>();
		interfaces = new ArrayList<StringInterface>();
		componentsWithInterfaces = new HashMap<String, ArrayList<StringInterface>>();
		componentsWithSuperComps = new HashMap<String, ArrayList<String>>();

	}

	
	/**
	 * @return the componentsWithInterfaces
	 */
	public HashMap<String, ArrayList<StringInterface>> getComponentsWithInterfaces() {
		return componentsWithInterfaces;
	}

	/**
	 * @return the componentsWithSuperComps
	 */
	public HashMap<String, ArrayList<String>> getComponentsWithSuperComps() {
		return componentsWithSuperComps;
	}

	/**
	 * @return the document
	 */
	public Document getDocument() {
		return document;
	}

	/**
	 * @return the text
	 */
	public String getText() {
		return text;
	}

	/**
	 * @return the components
	 */
	public ArrayList<String> getComponents() {
		return components;
	}

	/**
	 * @return the interfaces
	 */
	public ArrayList<StringInterface> getInterfaces() {
		return interfaces;
	}

	/**
	 * 
	 * @return the componenentsWithArgs
	 */

	public ArrayList<String> getComponentsWithArgs() {
		return componentsWithArgs;
	}
	
	/**
	 * Affichage d'un résumé des infos trouvées
	 */
	public void printSummary() {
		Collections.sort(components);
		for (String s : components) {
			System.out.println(s);
		}
		System.out.println("Nombre de composants trouvées : "
				+ components.size());
		System.out.println();
		System.out.println();
		for (StringInterface s : interfaces) {
			System.out.println(s.getName());;
		}
		System.out.println("Nombre d'interfaces trouvées : "
				+ interfaces.size());
	}

	/**
	 * Affichage des interfaces trouvées
	 */
	public void printInterfaces() {
		System.out.println("affichage des " + interfaces.size()
				+ " interfaces dans le fractal");
		for (StringInterface s : interfaces) {
			System.out.println(s.getName());
		}
	}

	/**
	 * Affichage des composants er de keur interfaces trouvées
	 */
	public void printComponentsWithInterfaces() {
		for (String s : componentsWithInterfaces.keySet()) {
			System.out.println(s);
			for (StringInterface si : componentsWithInterfaces.get(s)) {
				si.affiche();
			}
			System.out.println();

		}
	}

	/**
	 * Affichage des composants trouvés
	 */
	public void printComponents() {
		System.out.println("affichage des " + components.size()
				+ " composants dans le fractal");
		for (String s : components) {
			System.out.println(s);
		}
	}

	/**
	 * Affichage pleins de choses
	 */

	public void printAll() {

		System.out.println();
		System.out.println();
		System.out.println("affichage des composants et de leur(s) interfaces");
		for (String s : componentsWithInterfaces.keySet()) {
			System.out.println("Component " + s);
			for (StringInterface i : componentsWithInterfaces.get(s)) {
				i.affiche();
			}
			System.out.println();

		}
		System.out.println();
		System.out.println();

	}



}
